
#include "ScaleEffect.h"

ScaleEffect::ScaleEffect(RenderableEntity* _entity, float _fDuration, bool _bEnabled, bool _bLoop, Vector2 _vInitScale, Vector2 _vEndScale) : SpriteEffect(_entity, _fDuration, _bEnabled, _bLoop)
{
    setParams(_vInitScale, _vEndScale);
}

ScaleEffect::ScaleEffect(RenderableEntity* _entity, float _fDuration, bool _bEnabled, bool _bLoop, Vector2 _vEndScale) : SpriteEffect(_entity, _fDuration, _bEnabled, _bLoop)
{
    setParams(_vEndScale);
}

void ScaleEffect::updateEffect(float _fPerc)
{
    m_entity->setScale(m_vInitScale + (m_vEndScale - m_vInitScale) * _fPerc);
}

void ScaleEffect::setParams(Vector2 _vInitScale, Vector2 _vEndScale)
{
    m_vInitScale = _vInitScale;
    m_vEndScale = _vEndScale;
    m_bHasInit = true;
}

void ScaleEffect::setParams(Vector2 _vEndScale)
{
    m_vInitScale = m_entity->getScale();
    m_vEndScale = _vEndScale;
    m_bHasInit = false;
}

void ScaleEffect::enableEffect(bool _bValue)
{
	if(_bValue && !m_bHasInit)
	{
		m_vInitScale = m_entity->getScale();
	}
}
